<!-- DataTables CSS -->
<link href="<?=base_url('public')?>/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.css" rel="stylesheet">

<!-- DataTables Responsive CSS -->
<link href="<?=base_url('public')?>/bower_components/datatables-responsive/css/dataTables.responsive.css" rel="stylesheet">

<style type="text/css">
    td span{
        color: red;
    }
</style>

<div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">用户列表</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            管理所有用户
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <div class="dataTable_wrapper">
                                <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                    <thead>
                                        <tr>
                                            <th>用户ID</th>
                                            <th>真实姓名</th>
                                            <th>性别</th>
                                            <th>状态</th>
                                            <th>联系电话</th>
                                            <th>联系邮箱</th>
                                            <th>权限</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php foreach($list as $k => $v):?>
                                            <tr class="odd gradeX">
                                                <td><?=$v['id']?></td>
                                                <td class="center"><?=$v['name']?></td>
                                                <td><?=$v['sex']?></td>
                                                <td><?=$v['status'] == 1 ? '正常' : '<span>离职</span>'?></td>
                                                <td class="center"><?=$v['phone']?></td>
                                                <td class="center"><?=$v['email']?></td>
                                                <td><?=$v['group'] == 1 ? '<span>管理员</span>' : '普通用户'?></td>
                                                <td>
                                                <?php if($v['id'] != 1):?>
                                                    <a href="<?=site_url('users/edit?id='.$v['id'])?>">编辑</a>
                                                    <a href="javascript:;" onclick="sure('<?=$v['id']?>')">删除</a>
                                                <?php else:?>
                                                    <span>-----</span>
                                                <?php endif;?>
                                                </td>
                                            </tr>
                                        <?php endforeach;?>


                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
        </div>

<script src="<?=base_url('public')?>/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
<script src="<?=base_url('public')?>/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js"></script>
<script>
    $(document).ready(function() {
        $('#dataTables-example').DataTable({
                responsive: true
        });
    });
</script>
<script type="text/javascript">
 function sure(id){
        layer.confirm("是否要删除该用户", {
            icon:0,
            btn: ['确定','取消'] //按钮
        }, function(){
            $.get("<?=site_url('users/del')?>",{id:id},function(data){
                if(data == 1){
                    layer.alert("操作成功！",{
                        icon:1,
                    },function(){
                        location.reload();
                    });
                }else{
                    layer.alert(data,{
                        icon:2,
                    });
                }
            });
        });
    }
</script>